<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	
	<xsl:include href="../admin.xsl" />
	<xsl:include href="../cp/path.xsl" />
	<xsl:include href="../common/navigation.xsl" />
	
	<!-- Запускаем рендер страницы -->
	<xsl:template match="/data">
		<html>
		
		<head>
			<title>
				<xsl:value-of select="$pageTitle" />
			</title>
			<xsl:call-template name="meta-head" />
		</head>
		<body>
			<xsl:call-template name="admin-header" />
			
			<div id="blocks">
				<div id="blocks_inner" />
			</div>
			
			<div id="content">
				<div id="content_inner">
					<xsl:apply-templates select="response" />
				</div>
			</div>
			
			<xsl:call-template name="footer" />
		</body>
		</html>
	</xsl:template>
	
	<xsl:template match="response">
		<div id="path">
			<xsl:apply-templates select="document('xmodule://cp/getPath/0;blogs;posts')/data/response" mode="cp-path" />
		</div>
		
		<h1>Список публикаций</h1>
		
		<xsl:apply-templates select="message" />
		
		<table class="standart" cellspacing="0" cellpadding="0">
			<tbody>
				<xsl:apply-templates select="object" />
			</tbody>
		</table>
		
		<xsl:apply-templates select="pages" mode="pages-navigation">
			<xsl:with-param name="href">
				<xsl:value-of select="$baseURI" />
				<xsl:text>/admin/blogs/posts</xsl:text>
			</xsl:with-param>
		</xsl:apply-templates>
	</xsl:template>
	
	<xsl:template match="object">
		<xsl:param name="userLogin" select="property[@name='user_login']/value" />
		<xsl:param name="blogAlias" select="property[@name='blog_alias']/value" />
		
		<xsl:if test="position() = 1">
			<tr>
				<th>Заголовок</th>
				<th>Автор</th>
				<th>Блог</th>
				<th>Дата</th>
				<th>Опции</th>
			</tr>
		</xsl:if>
		
		<tr>
			<td>
				<a class="mainlink" title="Перейти">
					<xsl:attribute name="href">
						<xsl:value-of select="concat($baseURI, '/post/', @type, '/', @id)" />
					</xsl:attribute>
					<xsl:value-of select="property[@name='title']/value" />
				</a>
			</td>
			<td>
				<a href="{$baseURI}/user/{$userLogin}">
					<xsl:value-of select="property[@name='user_name']/value" />
				</a>
			</td>
			<td>
				<a href="{$baseURI}/blog/{$blogAlias}">
					<xsl:value-of select="property[@name='blog_title']/value" />
				</a>
			</td>
			<td>
				<xsl:value-of select="property[@name='pubdate']/value" />
			</td>
			<td>
				<a href="{$baseURI}/admin/blogs/delete_post/{@type-id}/{@id}?scode={$scode}" onclick="if(!confirm('Вы действительно хотите удалить эту публикацию?'))return false;">удалить</a>
			</td>
		</tr>
	</xsl:template>
	
</xsl:stylesheet>